package action.agent;

import org.apache.struts2.ServletActionContext;

import service.interf.IUserBind;
import action.common.MyBaseAction;

import com.opensymphony.xwork2.ModelDriven;

import dao.pojo.UserBind;

/**
 * 用户绑定
 * 
 * @author Administrator
 * 
 */
public class UserBindAction extends MyBaseAction<UserBind> implements
		ModelDriven<UserBind> {

	private static final long serialVersionUID = 1L;
	private IUserBind iUserBind;

	public void setiUserBind(IUserBind iUserBind) {
		this.iUserBind = iUserBind;
	}

	public UserBindAction() {
		super(UserBind.class);
	}

	public UserBind getModel() {
		return model;
	}

	/**
	 * 初始化列表
	 */
	public void getlist() {
		String r;
		try {
			r = iUserBind.findByProperty("UserBind", "*", "json", true, null,
					null, null, null, model.getPage(), model.getRows());
		} catch (Exception e) {
			r = errorHandle.handleErr(e);
		}
		servletHandle.writeToClient(ServletActionContext.getResponse(), r);
	}

	/**
	 * 绑定
	 */
	public void bindyes() {
		String r;
		try {
			r = iUserBind.bindYes(model);
		} catch (Exception e) {
			r = errorHandle.handleErr(e);
		}
		servletHandle.writeToClient1(ServletActionContext.getResponse(), r);
	}

	/**
	 * 解除绑定
	 */
	public void bindno() {
		String r;
		try {
			r = iUserBind.bindNo(model);
		} catch (Exception e) {
			r = errorHandle.handleErr(e);
		}
		servletHandle.writeToClient1(ServletActionContext.getResponse(), r);
	}

	/**
	 * 获取当前登录代理商下的所有代理商（累积充值点数、本月新增点数、剩余点数）
	 */
	public void getmybinduser() {
		String r;
		try {
			r = iUserBind.getMyBindUser(model.getPage(), model.getRows());
		} catch (Exception e) {
			r = errorHandle.handleErr(e);
		}
		servletHandle.writeToClient(ServletActionContext.getResponse(), r);
	}

}
